<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div id="Mydiv"></div>
<script type="text/javascript" src="plugins/vue/dist/vue.js"></script>
<script type="text/javascript" src="plugins/axios/dist/axios.js"></script>
<script type="text/javascript" src="script/common.js"></script>

<script type="text/javascript">
    new Vue({
        el:"#Mydiv",
        mounted(){
            let paramObj = urlgetobj(location.href);
            this.$http.post("/login/wechat",paramObj)
                .then(result => {
                    result = result.data;
                    if(result.success){ // 登陆成功要将token和loginUser存入localStorage中
                        // 将token和loginUser存入localStorage中
                        localStorage.setItem("token",result.data.token);
                        localStorage.setItem("loginUser",JSON.stringify(result.data.loginUser));
                        alert("登陆成功!");
                        // 跳转到首页
                        location.href="/index.html";
                    }else{
                            let {accessToken,openId} = result.data;
                            alert(accessToken,openId);
                            location.href = "/binder.html?accessToken="+accessToken+"&openid="+openId;

                    }
                })
        }

    })
</script>

</body>
</html>